package com.news.yp.baselibrary.base;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


public abstract class MyBaseFragment extends Fragment {

    private View viewRoot;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        viewRoot = setView(inflater, container);
        initView();
        initData();
        return viewRoot;
    }


    /**
     * 返回一个View,填充一个Fragemnt自己的布局视图
     *
     * @param inflater
     * @param container
     * @return
     */
    protected abstract View setView(LayoutInflater inflater, ViewGroup container);

    /**
     * 初始化数据
     */
    protected abstract void initData();

    /**
     * 初始化View，比如findViewByID
     */
    protected abstract void initView();

}
